<template>
  <el-card header="风险预警管理">
    <div class="tree-box">
      <div class="btns">
        <el-button type="primary" @click="add">新增</el-button>
        <el-input
          v-model="value"
          placeholder="请输入创建时间/标题/发文字号 关键字"
          :suffix-icon="Search"
          style="width: 420px"
        />
      </div>
      <MTable
        :columns="columns"
        :http="msgPage"
        :params="params"
        v-model:isReload="isReload"
        v-model:selectKeys="selectKeys"
      >
        <template #附件="{ row }">
          <MA>{{ row.files.length || 0 }}</MA>
        </template>
        <template #actions="{ row }">
          <MA type="primary" @click="toDetail(row.sorgResultPublicityId)"
            >查看</MA
          >
          <MA type="primary" @click="add(row.sorgResultPublicityId)">编辑</MA>
          <MA
            type="primary"
            @click="setInstitutionDel(row.sorgResultPublicityId)"
          >
            删除
          </MA>
        </template>
      </MTable>
    </div>
  </el-card>
  <AddForm ref="AddFormRef" @reload="reload" />
</template>

<script setup lang="ts">
import { ref, reactive, nextTick } from 'vue'
import { columns, fields, dialogFields } from './config'
import { logExport, logList } from '@/api/system/logManagement'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import AddForm from './components/addForm/addForm.vue'
import { msgDel, msgPage, soptCheckDel } from '@/api/spotCheck/spotCheck'

const router = useRouter()
defineOptions({
  name: 'logManagement'
})

// 搜索
const params = ref<any>({})
const search = (data: any) => {
  params.value = {
    ...params.value,
    ...data
  }
}

// 删除
const selectKeys = ref<number[]>([])
const clearSelectKeysReload = () => {
  selectKeys.value = []
  reload()
}

// 重载
const isReload = ref(true)
const reload = () => {
  isReload.value = true
}

const openDialog = () => {
  dialogVisible.value = true
}

const options = ref([
  {
    label: '主题1',
    value: 1
  },
  {
    label: '主题2',
    value: 2
  },
  {
    label: '主题3',
    value: 3
  }
])

// 新增/编辑
const dialogVisible = ref(false)

const viewInfo = ref({})
const view = (row) => {
  viewInfo.value = row
  dialogVisible.value = true
}

//新增
const AddFormRef = ref()
const add = (id = 0) => {
  AddFormRef.value.show(id)
}

const toDetail = (id) => {
  router.push({
    name: 'InformationDisclosureView',
    query: {
      id
    }
  })
}

//批量删除
const setInstitutionDel = (e) => {
  msgDel({ sorgResultPublicityId: e }).then((res) => {
    ElMessage.success('删除成功！')
    reload()
  })
}
</script>
<style lang="scss" scoped>
.tree-box {
  position: relative;

  .nodeBox {
    width: 100%;
    height: 80vh;
    overflow-x: auto;
    cursor: all-scroll;
  }
  .showLevel {
    position: absolute;
    right: 0;
    top: 0;
  }
}
.dialog-row {
  width: 100%;
  .dialog-col {
    width: 100%;
    display: flex;
    .dialog-col-serialNumber {
      color: #333;
      height: 100%;
      display: flex;
      justify-content: center;
      align-content: center;
      font-weight: bold;
      margin-right: 20px;
    }
    .dialog-col-rig {
      flex: 1;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(237, 237, 237, 1);
      margin-bottom: 20px;
      padding-bottom: 20px;
      .dialog-col-rig-content {
        .dialog-col-rig-content-title {
          font-size: 13px;
          color: #666;
          margin-bottom: 20px;
        }
        .dialog-col-rig-content-form {
          font-size: 13px;
          color: #999;
        }
      }
    }
  }
}
.btns {
  display: flex;
  flex-direction: row-reverse;
}
.ml-20 {
  margin-left: 20px;
}
.ml-12 {
  margin-left: 12px;
}
:deep(.search .el-form-item__label) {
  width: 72px !important;
}
.grade {
  width: 27px;
  height: 27px;
}
.btns {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  flex-direction: row;
}
</style>
